//
//  PAAboutView.m
//  PAMobileWallet
//
//  Created by shen pu on 13-7-18.
//  Copyright (c) 2013年 平安付. All rights reserved.
//

#import "PAAboutView.h"

@implementation PAAboutView
@synthesize titleLable;
@synthesize authScrollerView;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        NSString * agreementText = [[NSBundle mainBundle] pathForResource:@"AboutAgreement" ofType:@"txt"];
        NSString * agreementStr = [NSString stringWithContentsOfFile:agreementText encoding:NSUTF8StringEncoding error:nil];
        
        CGFloat x, y, w, h;

        x = 0; y = 44; w = 320; h = iPhone5?548:460 - 44;
        authScrollerView = [[UIScrollView alloc] initWithFrame:CGRectMake(x, y, w, h)];
        authScrollerView.delegate = self;
        authScrollerView.pagingEnabled = NO;
        authScrollerView.showsVerticalScrollIndicator = NO;
        authScrollerView.showsHorizontalScrollIndicator = NO;
        authScrollerView.backgroundColor = [UIColor clearColor];
        [self addSubview:authScrollerView];

        x = 10; y = 20; w = 300; h = 40;
        self.titleLable = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w, h)];
        self.titleLable.backgroundColor = [UIColor clearColor];
        self.titleLable.textAlignment = UITextAlignmentLeft;
        self.titleLable.textColor = [UIColor darkTextColor];
        self.titleLable.text = agreementStr;
        
        [self.titleLable setNumberOfLines:0];
        UIFont * font = [UIFont fontWithName:@"Arial" size:14];
        self.titleLable.font = font;
        [authScrollerView addSubview:self.titleLable];

        CGSize constraint = CGSizeMake(300, 20000.0f);
        CGSize size = [agreementStr sizeWithFont:font constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
        [self.titleLable setFrame:CGRectMake(10, 20, 300, size.height)];

        CGSize newSizeT = CGSizeMake(320, size.height + 300);
        [authScrollerView setContentSize:newSizeT];
    }
    return self;
}


@end
